package com.javabasic2.paintserver;

import java.util.Vector;

public class ClientList {
	
	private Vector<Object> members = new Vector<Object>();
	
	public void clientAdd(Client client) {
        members.add(client);
        Object obj = null;
        SendAll(obj);
    }
	
	public void SendAll(Object obj) {
        for ( int i = 0 ; i < members.size() ; i++) {
            ((Client)members.get(i)).SendMessage(obj);
        }
    }
	public void removeClient(String ID) {
        for ( int i = 0 ; i < members.size() ; i++) {
            if(((Client)members.get(i)).userID.equals(ID)) {
            	members.remove((Client)members.get(i));
            }   
        }
    }
	public int getSize() {
		return members.size();
	}


	public void closed() {
		synchronized (members) {
			for (int i = 0; i < members.size(); i++) {
				((Client) members.get(i)).closed();
			}
		}
	}
}
